
import ajax from '../utils/request'
import { ParamsProps } from './api.d'

// 1. 获取商品列表接口
export const FetchGoodsList = ({page, size}:ParamsProps) => {
  return ajax.get('/api/findGoods', {
    params: {page, size}
  })
}

// 加入购物车接口
export const FetchToCart = ({skuId}: { skuId:string }) => {
  return ajax.get('/api/toCartItem', { params: {skuId} })
}

// 获取已经加入购物车的列表数据
export const FetchCartList = ({page, size}:ParamsProps) => {
  return ajax.get('/api/findCartList', {
    params: {page, size}
  })
}

// 2. ++ -- 接口
export const FetchUpdateCount = ({skuCount, skuId}:ParamsProps) => {
  return ajax.post('/api/updateSkuount', {skuCount, skuId})
}

// 3. 总价接口
export const FetchTotalPrice = () => {
  // api/allCartListPrice
  return ajax.get('/api/allCartListPrice')
}

// 4. 详情接口
// export const Fetch


// 删除购物车列表接口/api/deleteCartItem
export const FetchDeleteCartItem = ({skuId}: {skuId: string}) => {
  return ajax.delete(`/api/deleteCartItem/${skuId}`)
}